package com.example.cstr.service.serviceImpl;

import com.example.cstr.entity.ExchangeRules;
import com.example.cstr.entity.Message;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.example.cstr.entity.EducationTrainProject;
import com.example.cstr.mapper.EducationTrainProjectMapper;
import com.example.cstr.service.EducationTrainProjectService;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class EducationTrainProjectServiceImpl implements EducationTrainProjectService {

    @Resource
    private EducationTrainProjectMapper educationTrainProjectMapper;

    @Override
    public int deleteByPrimaryKey(Integer etpId) {
        return educationTrainProjectMapper.deleteByPrimaryKey(etpId);
    }

    @Override
    public int insert(EducationTrainProject record) {
        return educationTrainProjectMapper.insert(record);
    }

    @Override
    public int insertSelective(EducationTrainProject record) {
        if (record.getEtpMaxTime() == null){
            record.setEtpMaxTime(-1);
        }
        return educationTrainProjectMapper.insertSelective(record);
    }

    @Override
    public EducationTrainProject selectByPrimaryKey(Integer etpId) {
        return educationTrainProjectMapper.selectByPrimaryKey(etpId);
    }

    @Override
    public int updateByPrimaryKeySelective(EducationTrainProject record) {
        return educationTrainProjectMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(EducationTrainProject record) {
        return educationTrainProjectMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<EducationTrainProject> selectAllEducationTrainProject() {
        return educationTrainProjectMapper.selectAllEducationTrainProject();
    }

    @Override
    public Message PagingSearch(@RequestParam Integer pageNum, @RequestParam Integer size) {
        PageHelper.startPage(pageNum, size);
        List<EducationTrainProject> educationTrainProjectList = educationTrainProjectMapper.selectAllEducationTrainProject();
        PageInfo pageInfo = new PageInfo(educationTrainProjectList);
        pageInfo.getTotal();
        return Message.success(null).add(pageInfo);
    }

    @Override
    public List<EducationTrainProject> selectByEtp_parent_id(Integer etp_parent_id) {
        return educationTrainProjectMapper.selectByEtp_parent_id(etp_parent_id);
    }

    @Override
    public List<EducationTrainProject> selectEtpIdIdByWorkId(Integer workId) {
        return educationTrainProjectMapper.selectEtpIdIdByWorkId(workId);
    }
}








